package com.example.xymarket.httpUtil;

import com.example.xymarket.common.HttpCon;
import com.example.xymarket.common.MyJson;
import com.example.xymarket.common.MyUrl;

import java.util.HashMap;
import java.util.Map;

public class UserInfoService {

    static public int isLogin=0;
    public static void check(String username, String password)
    {
        new Thread(new Runnable(){
            @Override
            public void run() {
                Map<String,String> userinfo=new HashMap<>();
                userinfo.put("username",username);
                userinfo.put("password",password);
                String res = null;
                try {
                    res = HttpCon.OKPost(MyUrl.SSOUrl+"login?",userinfo,null,null);
                } catch(Exception e) {
                    e.printStackTrace();
                }
                if(MyJson.getCode(res)==0) {
                    MyJson.JsonToToken(res);
                    res = HttpCon.getUserInfoMessage();
                    if(MyJson.getCode(res)==0)
                    {
                        MyJson.JsonToUserInfo(res);
                        isLogin=1;
                    }
                }
                else isLogin=-1;
            }
        }).start();
    }

    public static void getUserInfo()
    {
        new Thread(new Runnable(){
            @Override
            public void run() {

            }
        }).start();
    }
}
